import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:search_people/entrance/route/routes.dart';
import 'package:search_people/utils/component/component.dart';

import '../../../../utils/img_util.dart';
import '../../../../value/topcolors.dart';
import 'index.dart';
import 'widgets/widgets.dart';

class HotPeoplePage extends GetView<HotPeopleController> {
  const HotPeoplePage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    return ListView.separated(
        itemBuilder: (ctx, index) {
          var e = controller.state.hots[index];
          return InkWell(
            onTap: () {
              Get.toNamed(RouterPath.person_detail, arguments: e.leaderId);
            },
            child: Container(
              decoration: BoxDecoration(
                  color: Colors.white,
                  border: Border(bottom: BorderSide(color: TopColors.bg))),
              padding: EdgeInsets.symmetric(horizontal: 12.r, vertical: 10.r),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    e.leaderName ?? '',
                    style:
                        TextStyle(color: TopColors.black_33, fontSize: 12.sp),
                  ),
                  Text(
                    e.currentPosition ?? '',
                    style:
                        TextStyle(color: TopColors.black_99, fontSize: 11.sp),
                  ),
                ],
              ),
            ),
          );
        },
        separatorBuilder: (context, index) {
          return Container(
            height: 1,
            color: TopColors.bg,
          );
        },
        itemCount: controller.state.hots.length);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HotPeopleController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(context, title: '热门人物'),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
